package com.yf.user.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class DrMemberCarry {
    /**
     * 主键id 自增  
     */
    private Integer id;

    /**
     * 会员ID  
     */
    private Integer uid;

    /**
     * 绑定银行（当前）  
     */
    private Integer bankId;

    /**
     * 金额  
     */
    private BigDecimal amount;

    /**
     * 提现手续费 
     */
    private BigDecimal poundage;

    /**
     * 提现状态，1 成功 2失败 3 冻结
     */
    private Integer status;

    /**
     * 提交时间  
     */
    private Date addTime;

    /**
     * 审核人 
     */
    private Integer auditId;

    /**
     * 审核时间（不论失败或成功）
     */
    private Date auditTime;

    /**
     * 银行卡号  
     */
    private String bankNum;
    private String bankName;//银行卡名

    /**
     * 提现渠道 0 线上 1 后台  
     */
    private Integer channel;
    private String paymentNum;//商户唯一订单号
    private String reason;//失败原因
    
    private Integer type;//1.连连2金运通


	private Integer refundStatus; //0退还失败 1退还成功
	private String refundResult;
	private Date refundDate;
	private String refundSerialNumber;

	private Integer poundageStatus;//0 支付手续费状态失败 1 支付成功
	private String poundageResult;
	private Date poundageDate;
	private String poundageSerialNumber;

	private Integer version; //乐观锁版本号

	private String cashWay; //T+0, T+1

	@AllArgsConstructor
	@Getter
	public enum ChannelEnum {

		PC(0, "PC"),
		OP(4, "OP"),
		IOS(1, "IOS"),
		WE_CHAT(3, "WeChat"),
		ANDROID(2, "android");

		private Integer code;
		private String contents;

	}

	@AllArgsConstructor
	@Getter
	public enum StatusEnum {

		FAILURE(3, "失败受理"),
		SUCCESS(2, "成功受理"),
		REFUND(6, "退票"),
		INIT(0, "初始化");

		private Integer code;
		private String contents;

	}

	@AllArgsConstructor
	@Getter
	public enum RefundStatusEnum {

		REFUND_FAILED(0, "退还手续费失败"),
		REFUND_SUCCESS(1, "退还手续费成功");

		private Integer code;
		private String contents;

	}

	@AllArgsConstructor
	@Getter
	public enum PoundageStatusEnum {

		POUNDAGE_FAILED(0, "支付手续失败"),
		POUNDAGE_SUCCESS(1, "支付手续成功");

		private Integer code;
		private String contents;

	}

	public boolean isSuccessedCarry(){
		return StatusEnum.SUCCESS.getCode().equals(status);
	}

	public boolean havePoundage(){
		return poundage.compareTo(BigDecimal.ZERO) > 0;
	}

	public String getPoundageString(){

		String poundageStr = poundage.multiply(new BigDecimal(100)).toString();

		if (! (poundageStr.indexOf(".") == -1)) {

			poundageStr =  poundageStr.substring(0,poundageStr.indexOf("."));
		}
		return poundageStr;
	}

	
}